<template>
  <div class="image-lists">
    <div class="image-lists-title">
      {{title}}
    </div>
    <div class="contant-list">
      <div
        class="one-img"
        v-for="img in imgs"
        @click="onclick(img)"
        :key="img.id">
        <el-image
          :src="img.url"
          fit="cover"></el-image>
        <span class="demonstration">{{ img.label }}</span>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  // 用于图片列表展示，每个图片包含文字和链接可点击
  name: 'imageLists',
  data () {
    return {
    }
  },
  // imgs 图片数据
  // imgs [ { id: 1, label: 'xxx', url:'xxxx', goto: '' }]
  props: [ 'imgs', 'title', 'choosedImg' ],
  methods: {
    onclick (img) {
      this.$emit('update:choosedImg', img)
    }
  }
}
</script>

<style lang="scss">
.image-lists {
  .image-lists-title {
    text-align: center;
    font-size: 25px;
    padding: 10px;
    background-color: #f3923d;
    width: 380px;
    margin: 0 auto;
    color: #ffffff;
  }
  .contant-list {
    margin-top: 15px;
    display: grid;
    grid-template-columns: 300px 300px 300px;
    grid-gap: 10px;
    justify-content: center;
    align-content: center;

    .one-img {
      cursor: pointer;
      .demonstration {
        display: block;
        text-align: center;
      }
      .el-image {
        width: 300px;
        height: 250px;
      }

      &:hover {
        background-color: #f3923d;
        color: #ffffff;
        text-decoration: underline;
      }

    }
  }

}
</style>
